﻿using System.Diagnostics;
using MyCompany.WebCrawler.Interfaces;
using MyCompany.WebCrawler.Repositories;

namespace MyCompany.WebCrawler.Tasks.Tasks
{
    public class ShowNewLinksTask : ITask
    {
        private readonly IUiFetcher uiFetcher;
        private readonly IRepository repository;

        public ShowNewLinksTask(IUiFetcher uiFetcher, IRepository repository)
        {
            this.uiFetcher = uiFetcher;
            this.repository = repository;
        }

        public void Execute()
        {
            var urls = repository.Load();
            urls.ForEach(u => uiFetcher.Show(u.Path));
        }


        public override string ToString()
        {
            Trace.WriteLine("ShowNewLinksTask.");
            return base.ToString();
        }
    }
}